package com.semp.jadoma.admin.action;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;

import com.semp.jadoma.admin.utils.Config;

public class InitServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2915593692139014103L;
	private final static Logger logger = Logger.getLogger(InitServlet.class);
	
	@Override
	public void init() throws ServletException {
		super.init();
		String imgRealPath =  this.getServletContext().getRealPath("") + File.separator +  Config.IMAGE_PATH;
		File file = new File(imgRealPath);
		if (file.exists() && file.isDirectory()) {
			try {
				Config.IMAGE_FULL_PATH = file.getCanonicalPath();
				logger.debug("Set image path: " + Config.IMAGE_FULL_PATH);
			} catch (IOException e) {
				logger.warn("Please create folder: " + imgRealPath);
			}
		} else {
			logger.warn("Please create folder: " + imgRealPath);
		}
	}
}
